<?php

namespace Proj\ResManBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

use Proj\ResManBundle\Entity\Project;

class DefaultController extends Controller
{
    /**
     * @Route("/")
     * @Route("/index")
     * @Template()
     */
    public function indexAction(Request $request)
    {
        return $this->redirect($this->generateUrl("public_research_projects"));
        
//        $path = $request->getUri();
//        $baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
//        $schedule_contents = file("$baseurl/bundles/projresman/imported/orar.txt");
//        
//        $pages = array(
//           
//        );
//        return array(
//            'navigation' => $pages,
//            'path' => $baseurl,
//            'contents' => $schedule_contents
//            );
    }
    
    /**
     * @Route("/")
     * @Route("/index/projects", name="default_projects")
     * @Template()
     */
    public function projectsAction()
    {
        $em = $this->getDoctrine()->getManager();
        $projects = $em->getRepository('ProjResManBundle:Project')->findAll();
        
        return $this->render(
            'ProjResManBundle:Default:projects.html.twig',
            array('projects' => $projects)
        );
    }
    
     /**
     * @Route("/")
     * @Route("/index/resources")
     * @Template()
     */
    public function resourcesAction()
    {
        return $this->render('ProjResManBundle:Default:resources.html.twig');
    }
    
    /**
     * @Route("/")
     * @Route("/index/activities")
     * @Template()
     */
    public function activitiesAction()
    {
        return $this->render('ProjResManBundle:Default:activities.html.twig');
    }
}
